home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Devpac 2.12 disk 1.adf / examples / helloworld.s < prev   
Text File  |  1988-10-06  |  4KB  |  160 lines

  1.  
  2. * the 'Hello World' program in 68000 Assembler
  3. * the C version is on page 2-10 of the Intuition manual
  4.  
  5. * this source code (C) HiSoft 1987 All Rights Reserved
  6.  
  7. * for Devpac Amiga Version 2 the following symbols were changed
  8. * to avoid clashes with the new include files:
  9. * Screen->MyScreen, NewScreen->MyNewScreen
  10. * Window->MyWindow, NewWindow->MyNewWindow
  11.  
  12.     opt    c+,d+
  13.  
  14.     incdir    ":include/"
  15.  
  16.     include    exec/exec_lib.i
  17.     include    intuition/intuition.i
  18.     include    intuition/intuition_lib.i
  19.     include    graphics/graphics_lib.i
  20.     include    graphics/text.i
  21.  
  22. INTUITION_REV    equ    31        v1.1
  23. GRAPHICS_REV    equ    31        v1.1
  24.  
  25. * Open the intuition library
  26.  
  27.     moveq    #100,d4            default error return code
  28.  
  29.     moveq    #INTUITION_REV,d0    version
  30.     lea    int_name(pc),a1
  31.     CALLEXEC OpenLibrary
  32.     tst.l    d0
  33.     beq    exit_false        if failed then quit
  34.     move.l    d0,_IntuitionBase    else save the pointer
  35.  
  36.     moveq    #GRAPHICS_REV,d0
  37.     lea    graf_name(pc),a1
  38.     CALLEXEC OpenLibrary
  39.     tst.l    d0
  40.     beq    exit_closeint        if failed then close Int, exit
  41.     move.l    d0,_GfxBase
  42.  
  43.     lea    MyNewScreen(pc),a0
  44.     CALLINT    OpenScreen        open a screen
  45.     tst.l    d0
  46.     beq    exit_closeall        if failed the close both, exit
  47.     move.l    d0,MyScreen
  48.  
  49. * now initialise a NewWindow structure. This is normally easier to
  50. * do with dc.w/dc.l statement etc, but for comparison with the C
  51. * version we do it like this
  52.     lea    MyNewWindow(pc),a0    good place to start
  53.     move.w    #20,nw_LeftEdge(a0)
  54.     move.w    #20,nw_TopEdge(a0)
  55.     move.w    #300,nw_Width(a0)
  56.     move.w    #100,nw_Height(a0)
  57.     move.b    #0,nw_DetailPen(a0)
  58.     move.b    #1,nw_BlockPen(a0)
  59.     move.l    #window_title,nw_Title(a0)
  60. _temp    set    WINDOWCLOSE!SMART_REFRESH!ACTIVATE!WINDOWSIZING
  61.     move.l    #_temp!WINDOWDRAG!WINDOWDEPTH,nw_Flags(a0)
  62.     move.l    #CLOSEWINDOW,nw_IDCMPFlags(a0)
  63.     move.w    #CUSTOMSCREEN,nw_Type(a0)
  64.     clr.l    nw_FirstGadget(a0)
  65.     clr.l    nw_CheckMark(a0)
  66.     move.l    MyScreen(pc),nw_Screen(a0)
  67.     clr.l    nw_BitMap(a0)
  68.     move.w    #100,nw_MinWidth(a0)
  69.     move.w    #25,nw_MinHeight(a0)
  70.     move.w    #640,nw_MaxWidth(a0)
  71.     move.w    #200,nw_MaxHeight(a0)
  72.  
  73. * thats it set up, now open the window (a0=NewWindow already)
  74.     CALLINT    OpenWindow
  75.     tst.l    d0
  76.     beq    exit_closescr            if failed
  77.     move.l    d0,MyWindow            save it
  78.  
  79.     move.l    d0,a1                window
  80.     move.l    wd_RPort(a1),a1            rastport
  81.     moveq    #20,d0                X
  82.     moveq    #20,d1                Y
  83.     CALLGRAF Move                move the cursor
  84.  
  85.     move.l    MyWindow(pc),a0
  86.     move.l    wd_RPort(a0),a1            rastport
  87.     lea    hello_message(pc),a0
  88.     moveq    #11,d0
  89.     CALLGRAF Text                print something
  90.  
  91.     move.l    MyWindow(pc),a0
  92.     move.l    wd_UserPort(a0),a0
  93.     move.b    MP_SIGBIT(a0),d1        (misprint in manual)
  94.     moveq    #0,d0
  95.     bset    d1,d0                do a shift
  96.     CALLEXEC Wait
  97.  
  98.     moveq    #0,d4                return code
  99.  
  100. * various exit routines that do tidying up, given a return code in d4
  101.  
  102.     move.l    MyWindow(pc),a0
  103.     CALLINT CloseWindow
  104.  
  105. exit_closescr
  106.     move.l    MyScreen(pc),a0
  107.     CALLINT CloseScreen
  108.  
  109. exit_closeall
  110.     move.l    _GfxBase(pc),a1
  111.     CALLEXEC CloseLibrary
  112.  
  113. exit_closeint
  114.     move.l    _IntuitionBase(pc),a1
  115.     CALLEXEC CloseLibrary
  116.  
  117. exit_false
  118.     move.l    d4,d0                return code
  119.     rts
  120.  
  121. * the definition of the screen - note that in assembler you
  122. * MUST get the sizes of these fields correct, by consulting either
  123. * the RKM or the header files
  124.  
  125. MyNewScreen    dc.w    0,0        left, top
  126.         dc.w    320,200        width, height
  127.         dc.w    2        depth
  128.         dc.b    0,1        pens
  129.         dc.w    0        viewmodes
  130.         dc.w    CUSTOMSCREEN    type
  131.         dc.l    MyFont        font
  132.         dc.l    screen_title    title
  133.         dc.l    0        gadgets
  134.         dc.l    0        bitmap
  135.  
  136. * my font definition
  137. MyFont    dc.l    font_name
  138.     dc.w    TOPAZ_SIXTY
  139.     dc.b    FS_NORMAL
  140.     dc.b    FPF_ROMFONT
  141.  
  142. * the variables
  143. _IntuitionBase    dc.l    0        Intuition lib pointer
  144. _GfxBase    dc.l    0        graphics lib pointer
  145. MyScreen        dc.l    0
  146. MyWindow        dc.l    0
  147. MyNewWindow    ds.b    nw_SIZE        a buffer
  148.  
  149.  
  150. * some strings
  151. int_name    INTNAME
  152. graf_name    GRAFNAME
  153. hello_message    dc.b    'Hello World'
  154.  
  155. * these are C strings, so have to be null terminated
  156. screen_title    dc.b    'My Own Screen',0
  157. font_name    dc.b    'topaz.font',0
  158. window_title    dc.b    'A Simple Window',0
  159.  
  160.